Skip to content

fix(type-safety): replace manual typeguards with valibot in SPA & reddit-fetch - #3313

Merged
louisgv merged 1 commit into
mainfrom
fix/valibot-typeguards-3200
Apr 16, 2026
Merged

fix(type-safety): replace manual typeguards with valibot in SPA & reddit-fetch#3313
louisgv merged 1 commit into
mainfrom
fix/valibot-typeguards-3200

Conversation

@la14-1

@la14-1 la14-1 commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces all as Record<string, unknown> casts and manual multi-level typeguard chains with valibot schema validation in SPA main.ts and reddit-fetch.ts
  • Adds RedditTokenSchema, RedditListingSchema, RedditChildDataSchema, and RedditCommentDataSchema with v.safeParse() for all external Reddit API data
  • Eliminates 15 type-safety violations (6 in main.ts, 9 in reddit-fetch.ts) flagged in security: Manual typeguards used instead of valibot validation in SPA code #3200

Files changed

  • .claude/skills/setup-spa/main.ts — Reddit token auth, error message parsing, jQuery-style comment URL extraction
  • .claude/skills/setup-agent-team/reddit-fetch.ts — Reddit auth, listing/post extraction, user comment fetching

Test plan

  • Verify bun build passes for both files (confirmed locally)
  • Verify no as casts remain in changed files (confirmed: grep returns zero matches)
  • Trigger a growth cycle to verify Reddit API parsing still works end-to-end
  • Verify SPA Reddit reply posting still extracts comment URLs correctly

Closes #3200

Filed from Slack by SPA

🤖 Generated with Claude Code

…PA and reddit-fetch

Replace all `as Record<string, unknown>` casts and manual multi-level
typeguard chains with proper valibot schema validation in:

- main.ts: Reddit token response, error parsing, jQuery comment URL extraction
- reddit-fetch.ts: Reddit auth, listing extraction, user comment fetching

Adds RedditTokenSchema, RedditListingSchema, RedditChildDataSchema, and
RedditCommentDataSchema with v.safeParse() for all external API data.

Closes #3200

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@louisgv
louisgv merged commit b290a3b into main Apr 16, 2026
6 checks passed
@louisgv
louisgv deleted the fix/valibot-typeguards-3200 branch April 16, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Manual typeguards used instead of valibot validation in SPA code

3 participants